<?php 
global $header;
global $footer;
global $control;
global $message;
global $glossary, $terms, $pageNav, $category, $count;

$isEditor = Utils::hasRight('glossary.edit');
global $featureManager;
$header['title'] = $glossary['abbr'] != ""?$glossary['abbr']:$glossary['title'];
if($isEditor) $header['head'] = '
<link rel="stylesheet" type="text/css" href="'.RESOURCE_BASE.'jqueryui/dialog/jquery-ui-1.7.2.dialog.css" />
<script type="text/javascript" src="'.RESOURCE_BASE.'jqueryui/dialog/jquery-ui-1.7.2.dialog.min.js"></script>
<script type="text/javascript" src="'.RESOURCE_BASE.'glossary/base.js"></script>
';
$header['intro'] = '<em class="title">'.$glossary['title'].'</em>';
$header['hasToolBar'] = TRUE;
$featureManager->apply("com.yizin.platform.site.header", $header);
$featureManager->apply("com.yizin.platform.site.footer", $footer);
$featureManager->apply("com.yizin.platform.site.control", $control);


global $iscontrol;
$iscontrol = $isEditor;

?>
<?= $header['html']?>
<div class="container-L">
	<?=$control['html']?>
</div>
<div class="container-R">
	<?=Utils::showMessage($message)?>
	<?=Utils::loadSegment(dirname(__FILE__)."/segments/_s_glossary_toolbar_.php")?>
	<?=Utils::loadSegment(dirname(__FILE__)."/segments/_s_glossary_search_.php")?>
	<?=Utils::loadSegment(dirname(__FILE__)."/segments/_s_glossary_category_.php")?>
	<p class="meta"><strong><?=$count?></strong> words in <em><?=$category==""?"ALL":$category?></em></p>
	<div class="vspacing-short"></div>
	<?php if($terms) {?>
	<table class="terms">
		<?php foreach($terms as $term) {?>
		<tr>
			<th>
				<em <?php if($isEditor) { ?>ondblclick="$(this).siblings('.circle-edit').click();"<?php }?> class="term"><?=$term['term']?></em>
				<?php if($isEditor) { ?>
				<a href="#" title="Edit" class="circle-edit" onclick="glossary.editterm_start(this, <?=$term['serial']?>);return false;">edit</a>
				<a href="#" title="Delete" class="circle-remove" onclick="glossary.delete_term(this, <?=$term['serial']?>);return false;">delete</a>
				<br />
				<a href="<?=REQUEST_BASE?>glossary/<?=$glossary['serial']?>/term/<?=$term['serial']?>/edit/" title="Edit">Edit a term</a>
				<?php }?>
			</th>
			<td>
				<p class="definition" <?php if($isEditor) { ?>ondblclick="$(this).siblings('.circle-edit').click();"<?php }?>><?=nl2br($term['definition'])?></p>
				<?php if($isEditor) { ?>
				<a href="#" title="Edit" class="circle-edit" onclick="glossary.editdefinition_start(this, <?=$term['serial']?>);return false;">edit</a>
				<?php }?><br />
				<?= $term['word_class'] ? "<br />Word Class: ".$term['word_class'] : "" ?>
				<?= $term['national_variants'] ? "<br />National variants: ".$term['national_variants'] : "" ?>
				<?= $term['admitted_terms'] ? "<br />Admitted terms: ".$term['admitted_terms'] : "" ?>
				<?= $term['deprecated_terms'] ? "<br />Deprecated terms: ".$term['deprecated_terms'] : "" ?>
				<?= $term['abbreviation'] ? "<br />Abbreviation: ".$term['abbreviation'] : "" ?>
				<?= $term['acronym'] ? "<br />Acronym: ".$term['acronym'] : "" ?>
				<?= $term['full_forms'] ? "<br />Full forms: ".$term['full_forms'] : "" ?>
				<?= $term['source_location'] ? "<br />Source location: ".$term['source_location'] : "" ?>
				<?= $term['subject_field'] ? "<br />Subject field: ".$term['subject_field'] : "" ?>
				<?= $term['broader_term'] ? "<br />Broader term: ".$term['broader_term'] : "" ?>
				<?= $term['narrower_term'] ? "<br />Narrower term: ".$term['narrower_term'] : "" ?>
				<?= $term['synonym'] ? "<br />Synonym: ".$term['synonym'] : "" ?>
				<?= $term['name_of_creators'] ? "<br />Name of creators: ".$term['name_of_creators'] : "" ?>
				<?= $term['notes'] ? "<br />Notes: ".$term['notes'] : "" ?>
			</td>
		</tr>
		<?php }?>
	</table>
	<?php }?>
	<?=$pageNav?>
</div>
<?= $footer['html']?>
